<?php
$t1 = microtime(true);
// 测试PHP执行python代码
  $bg_imag_path = '/www/wwwroot/python/beiji.jpg';
  $touxiang_imag_path = 'http://thirdwx.qlogo.cn/mmopen/PiajxSqBRaEJfVj4WCp9cSDKUwebfHeOibT2wcDwZnVOY3PebvESh5juDYLSpqCNFbViaq2zAOj3dU0XKiaZAicibU0Q/132';
  $ewm_imag_path = '/www/wwwroot/python/ewm.jpg';
  $name =  '杜瑞刚';
  unset($out);
  //在exec中第一个参数后添加 2>&1。如果python运行错误，将会把出错信息传递给$arr变量，然后就可以将arr变量的值输出到web端，以便差错。
//<?php  exec("/usr/bin/python test_english.py $firstname $secondname 2>&1",$arr,$ret);
//	print ("<xmp>");
//	print_r($arr);
//	print ("</xmp>");
//	echo "<br>" . $ret . "<br>";
  $c = exec("python image.py {$bg_imag_path} {$touxiang_imag_path} {$ewm_imag_path} {$name}",$out,$res);
  echo '执行返回的结果';
  print_r(urldecode($out[0]));
  echo "\r\n".PHP_EOL;
$t2 = microtime(true);
echo '程序耗时'.round($t2-$t1,3).'秒'.PHP_EOL;

//echo '外部程序运行是否成功:'.$res."(0代表成功,1代表失败)";
if($res == 0){
    echo '外部python 执行运行成功';
}
